//
//  JkmBaseTableViewController.swift
//  SinaWb
//
//  Created by Jiang on 16/5/9.
//  Copyright © 2016年 Jiang. All rights reserved.
//

import UIKit
import SVProgressHUD



class JkmBaseTableViewController: UITableViewController,VisitorViewDelegate {
    var Visitor : VisitorView?
    var userLogin = ViewModel.sharViewModel.userLogin

    internal  func ClickLogInButton() {
        let nvi = UINavigationController(rootViewController: LoginViewController())
        presentViewController(nvi, animated: true, completion: nil)
    }
    
    internal func ClickLogOnButton() {
    
    }
    
    override func loadView() {
        userLogin ? super.loadView() : loadVistorView()
    }
    
    private func loadVistorView(){
        Visitor = VisitorView()
        Visitor?.delegate = self
        view = Visitor
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if userLogin {
            
            return
        }
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录",
                                                                style: .Plain,
                                                                target: self,
                                                                action: #selector(ClickLogInButton))
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册",
                                                                 style: .Plain,
                                                                 target: self,
                                                                 action: #selector(ClickLogOnButton))
        
    }

}
